import requests
from bs4 import BeautifulSoup
import logging
import csv

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

proxy = {
    'http': 'http://127.0.0.1:7890',
    'https': 'http://127.0.0.1:7890'
}
def get_soup(url, headers):
    response = requests.get(url,headers=headers,proxies=proxy)
    response.encoding = 'utf-8'
    soup = BeautifulSoup(response.content, 'html.parser')
    return soup


# def get_data(soup):
#     data = []
#     for item in soup.find_all('li', class_='house-cell realverify'):
#         tem = item.find('p', class_='room').text.split('\xa0')
#         room = tem[0].strip()[0:1]
#         space = tem[-1].strip()[0:-1]
#         money = item.find('div', class_='money').text.strip()[0:-3]
#         data.append([room,space, money])
#     logging.info(soup.text[:1000])
#     logging.info(data)
#     if not data:
#         logging.info('data is empty')
#     return data


base_url = 'https://jx.58.com/chuzu/pn'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
                         'Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0'}
for i in range(2,71):
    data = []
    soup = get_soup('https://blog.csdn.net/?spm=1001.2014.3001.4477', headers)
    # data.extend(get_data(soup))